///*
// * Copyright (c) Facebook, Inc. and its affiliates.
// *
// * This source code is licensed under the MIT license found in the
// * LICENSE file in the root directory of this source tree.
// */
//
//package com.facebook.drawee.view;
//
//import com.facebook.drawee.drawable.ScalingUtils;
//import ohos.agp.animation.Animator;
//import ohos.agp.animation.AnimatorValue;
//import ohos.agp.components.ComponentContainer;
//import ohos.agp.transition.Transition;
//import ohos.agp.utils.Point;
//import ohos.agp.utils.Rect;
//
//import javax.annotation.Nullable;
//
///**
// * This Transition animates changes of {@link GenericDraweeView} between two ScaleTypes
// *
// * <p>In combination with ChangeBounds, DraweeTransition allows GenericDraweeViews that change size,
// * shape, or {@link ScalingUtils.ScaleType} to animate contents smoothly.
// */
//public class DraweeTransition extends Transition {
//
//  private static final String PROPNAME_BOUNDS = "draweeTransition:bounds";
//
//  private final ScalingUtils.ScaleType mFromScale;
//  private final ScalingUtils.ScaleType mToScale;
//  private final @Nullable Point mFromFocusPoint;
//  private final @Nullable Point mToFocusPoint;
//
//  public static TransitionSet createTransitionSet(
//      ScalingUtils.ScaleType fromScale, ScalingUtils.ScaleType toScale) {
//    return createTransitionSet(fromScale, toScale, null, null);
//  }
//
//  public static TransitionSet createTransitionSet(
//      ScalingUtils.ScaleType fromScale,
//      ScalingUtils.ScaleType toScale,
//      @Nullable Point fromFocusPoint,
//      @Nullable Point toFocusPoint) {
//    TransitionSet transitionSet = new TransitionSet();
//    transitionSet.addTransition(new ChangeBounds());
//    transitionSet.addTransition(
//        new DraweeTransition(fromScale, toScale, fromFocusPoint, toFocusPoint));
//    return transitionSet;
//  }
//
//  public DraweeTransition(
//      ScalingUtils.ScaleType fromScale,
//      ScalingUtils.ScaleType toScale,
//      @Nullable Point fromFocusPoint,
//      @Nullable Point toFocusPoint) {
//    mFromScale = fromScale;
//    mToScale = toScale;
//    mFromFocusPoint = fromFocusPoint;
//    mToFocusPoint = toFocusPoint;
//  }
//
//  public DraweeTransition(ScalingUtils.ScaleType fromScale, ScalingUtils.ScaleType toScale) {
//    this(fromScale, toScale, null, null);
//  }
//
//  @Override
//  public void captureStartValues(TransitionValues transitionValues) {
//    captureValues(transitionValues);
//  }
//
//  @Override
//  public void captureEndValues(TransitionValues transitionValues) {
//    captureValues(transitionValues);
//  }
//
//  @Override
//  public @Nullable Animator createAnimator(
//          ComponentContainer sceneRoot, TransitionValues startValues, TransitionValues endValues) {
//    if (startValues == null || endValues == null) {
//      return null;
//    }
//    Rect startBounds = (Rect) startValues.values.get(PROPNAME_BOUNDS);
//    Rect endBounds = (Rect) endValues.values.get(PROPNAME_BOUNDS);
//    if (startBounds == null || endBounds == null) {
//      return null;
//    }
//    if (mFromScale == mToScale && mFromFocusPoint == mToFocusPoint) {
//      return null;
//    }
//    final GenericDraweeView draweeView = (GenericDraweeView) startValues.view;
//    final ScalingUtils.InterpolatingScaleType scaleType =
//        new ScalingUtils.InterpolatingScaleType(
//            mFromScale, mToScale, startBounds, endBounds, mFromFocusPoint, mToFocusPoint);
//    draweeView.getHierarchy().setActualImageScaleType(scaleType);
//
//    AnimatorValue animator = new AnimatorValue();
//    animator.setValueUpdateListener(new AnimatorValue.ValueUpdateListener() {
//      @Override
//      public void onUpdate(AnimatorValue animatorValue, float v) {
//        scaleType.setValue(v);
//      }
//    });
//    animator.setStateChangedListener(new Animator.StateChangedListener() {
//      @Override
//      public void onStart(Animator animator) {
//
//      }
//
//      @Override
//      public void onStop(Animator animator) {
//
//      }
//
//      @Override
//      public void onCancel(Animator animator) {
//
//      }
//
//      @Override
//      public void onEnd(Animator animator) {
//        draweeView.getHierarchy().setActualImageScaleType(mToScale);
//        if (mToFocusPoint != null) {
//          draweeView.getHierarchy().setActualImageFocusPoint(mToFocusPoint);
//        }
//      }
//
//      @Override
//      public void onPause(Animator animator) {
//
//      }
//
//      @Override
//      public void onResume(Animator animator) {
//
//      }
//    });
////    animator.addUpdateListener(
////        new ValueAnimator.AnimatorUpdateListener() {
////          @Override
////          public void onAnimationUpdate(ValueAnimator animation) {
////            float fraction = (float) animation.getAnimatedValue();
////            scaleType.setValue(fraction);
////          }
////        });
////    animator.addListener(
////        new AnimatorListenerAdapter() {
////          @Override
////          public void onAnimationEnd(Animator animation) {
////            draweeView.getHierarchy().setActualImageScaleType(mToScale);
////            if (mToFocusPoint != null) {
////              draweeView.getHierarchy().setActualImageFocusPoint(mToFocusPoint);
////            }
////          }
////        });
//
//    return animator;
//  }
//
//  private void captureValues(TransitionValues transitionValues) {
//    if (transitionValues.view instanceof GenericDraweeView) {
//      transitionValues.values.put(
//          PROPNAME_BOUNDS,
//          new Rect(0, 0, transitionValues.view.getWidth(), transitionValues.view.getHeight()));
//    }
//  }
//}
